<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>11.state</title>
</head>

<body>
    <!-- 准备好一个容器 -->
    <div id="app"></div>
    <!-- 引入react核心库 -->
    <script type="text/javascript" src="../js/react.development.js"></script>
    <!-- 引入react-dom 用于支持 react 操作 dom -->
    <script type="text/javascript" src="../js/react-dom.development.js"></script>
    <!-- 引入 label，用于将 jsx 转化为 js -->
    <script type="text/javascript" src="../js/babel.min.js"></script>

    <!-- 此处必须写 text/babel -->
    <script type="text/babel">
        // 1. 创建类式组件
        // 注意：创建类式组件必须继承 React.Component
        class Demo extends React.Component {
            constructor(props) {
                super(props)
                this.state = { isWork: true }
            }
            render() {  // render 必须写，并且必须有返回值
                console.log(this)
                let { isWork } = this.state
                return <h1>老子今天{isWork ? '要' : '不'}上班！</h1>
            }
        }

        // 2. 渲染组件到页面
        ReactDOM.render(<Demo />, document.getElementById('app'))

    </script>

</body>

</html>